A Golang-based service for processing and analyzing vulnerability scan results. This service provides APIs to get scan results from a repo, upload scan results, query vulnerabilities.
- Retrieves JSON format files from a repo
- Processes vulnerability scan results in JSON format
- Stores vulnerability data in PostgreSQL database
- Queries vulnerabilities with filtering options
- Prevent duplicate entries
- Docker and Docker Compose
- Go 1.20 or higher (for local development)
- PostgreSQL 13 or higher (for local development)
/vulnerability
├── main.go # Application entrypoints
|── db # Database operations
|── db-init # Initial sql file eexy
|── models # Data models
|── server # HTTP handlers and routes
|── service # Business logic
├── Dockerfile # Docker build instructions
├── docker-compose.yml # Docker compose configuration
└── README.md # This file
- Clone the repository:
git clone https://github.com/dhbarman/vulnerability.git
cd vulnerability- Start the service using Docker Compose:
docker-compose up -d- The service will be available at
http://localhost:8080
POST /getfiles
Content-Type: application/json
POST /populatedb
Content-Type: application/jsonGET /query?severity=CRITICAL&status=active&package=nginxGET /health- Install dependencies:
go mod download- Set up the database:
psql -U postgres -f db-init/init.sql- Run the service:
go run ./main.goDATABASE_URL: PostgreSQL connection string (default: "postgresql://scanneruser:scannerpass@localhost:5432/scannerdb?sslmode=disable")PORT: Server port (default: 8080)APP_ENV: Application environment (development/production)
Run the tests:
go test ./...Build the Docker image:
docker build -t vuln-scanner .Run the container:
docker run -p 8080:8080 vuln-scanner{
"scan_id": "scan_123456789",
"timestamp": "2025-01-28T10:30:00Z",
"scan_status": "completed",
"resource_type": "container",
"resource_name": "app-container:latest",
"vulnerabilities": [
{
"id": "CVE-2024-1234",
"severity": "HIGH",
"cvss": 8.5,
"status": "fixed",
"package_name": "openssl",
"current_version": "1.1.1t-r0",
"fixed_version": "1.1.1u-r0",
"description": "Buffer overflow vulnerability in OpenSSL",
"published_date": "2024-01-15T00:00:00Z",
"link": "https://nvd.nist.gov/vuln/detail/CVE-2024-1234",
"risk_factors": [
"Remote Code Execution",
"High CVSS Score",
"Public Exploit Available"
]
}
]
}